using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class huqiang_UIComposite_ObjectLinker_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            MethodBase method;
            FieldInfo field;
            Type[] args;
            Type type = typeof(huqiang.UIComposite.ObjectLinker);
            args = new Type[]{typeof(System.Object)};
            method = type.GetMethod("AddData", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, AddData_0);
            args = new Type[]{};
            method = type.GetMethod("CreateUI", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, CreateUI_1);
            args = new Type[]{typeof(System.Object), typeof(System.Object), typeof(System.Int32)};
            method = type.GetMethod("RefreshItem", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, RefreshItem_2);
            args = new Type[]{typeof(System.Object)};
            method = type.GetMethod("LayoutItem", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, LayoutItem_3);

            field = type.GetField("ItemUpdate", flag);
            app.RegisterCLRFieldGetter(field, get_ItemUpdate_0);
            app.RegisterCLRFieldSetter(field, set_ItemUpdate_0);
            app.RegisterCLRFieldBinding(field, CopyToStack_ItemUpdate_0, AssignFromStack_ItemUpdate_0);
            field = type.GetField("ItemCreate", flag);
            app.RegisterCLRFieldGetter(field, get_ItemCreate_1);
            app.RegisterCLRFieldSetter(field, set_ItemCreate_1);
            app.RegisterCLRFieldBinding(field, CopyToStack_ItemCreate_1, AssignFromStack_ItemCreate_1);
            field = type.GetField("LayoutCallback", flag);
            app.RegisterCLRFieldGetter(field, get_LayoutCallback_2);
            app.RegisterCLRFieldSetter(field, set_LayoutCallback_2);
            app.RegisterCLRFieldBinding(field, CopyToStack_LayoutCallback_2, AssignFromStack_LayoutCallback_2);


            app.RegisterCLRCreateArrayInstance(type, s => new huqiang.UIComposite.ObjectLinker[s]);

            args = new Type[]{typeof(huqiang.UIComposite.UIContainer), typeof(huqiang.Core.HGUI.UIElement)};
            method = type.GetConstructor(flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Ctor_0);

        }


        static StackObject* AddData_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Object @dat = (System.Object)typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            huqiang.UIComposite.ObjectLinker instance_of_this_method = (huqiang.UIComposite.ObjectLinker)typeof(huqiang.UIComposite.ObjectLinker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.AddData(@dat);

            return __ret;
        }

        static StackObject* CreateUI_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            huqiang.UIComposite.ObjectLinker instance_of_this_method = (huqiang.UIComposite.ObjectLinker)typeof(huqiang.UIComposite.ObjectLinker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.CreateUI();

            object obj_result_of_this_method = result_of_this_method;
            if(obj_result_of_this_method is CrossBindingAdaptorType)
            {    
                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
            }
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static StackObject* RefreshItem_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 4);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Int32 @index = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Object @u = (System.Object)typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.Object @t = (System.Object)typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            huqiang.UIComposite.ObjectLinker instance_of_this_method = (huqiang.UIComposite.ObjectLinker)typeof(huqiang.UIComposite.ObjectLinker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.RefreshItem(@t, @u, @index);

            return __ret;
        }

        static StackObject* LayoutItem_3(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Object @u = (System.Object)typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            huqiang.UIComposite.ObjectLinker instance_of_this_method = (huqiang.UIComposite.ObjectLinker)typeof(huqiang.UIComposite.ObjectLinker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.LayoutItem(@u);

            __ret->ObjectType = ObjectTypes.Float;
            *(float*)&__ret->Value = result_of_this_method;
            return __ret + 1;
        }


        static object get_ItemUpdate_0(ref object o)
        {
            return ((huqiang.UIComposite.ObjectLinker)o).ItemUpdate;
        }

        static StackObject* CopyToStack_ItemUpdate_0(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.UIComposite.ObjectLinker)o).ItemUpdate;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_ItemUpdate_0(ref object o, object v)
        {
            ((huqiang.UIComposite.ObjectLinker)o).ItemUpdate = (System.Action<System.Object, System.Object, System.Int32>)v;
        }

        static StackObject* AssignFromStack_ItemUpdate_0(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Action<System.Object, System.Object, System.Int32> @ItemUpdate = (System.Action<System.Object, System.Object, System.Int32>)typeof(System.Action<System.Object, System.Object, System.Int32>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)8);
            ((huqiang.UIComposite.ObjectLinker)o).ItemUpdate = @ItemUpdate;
            return ptr_of_this_method;
        }

        static object get_ItemCreate_1(ref object o)
        {
            return ((huqiang.UIComposite.ObjectLinker)o).ItemCreate;
        }

        static StackObject* CopyToStack_ItemCreate_1(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.UIComposite.ObjectLinker)o).ItemCreate;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_ItemCreate_1(ref object o, object v)
        {
            ((huqiang.UIComposite.ObjectLinker)o).ItemCreate = (System.Action<huqiang.UIComposite.ObjectLinker, huqiang.UIComposite.LinkerMod>)v;
        }

        static StackObject* AssignFromStack_ItemCreate_1(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Action<huqiang.UIComposite.ObjectLinker, huqiang.UIComposite.LinkerMod> @ItemCreate = (System.Action<huqiang.UIComposite.ObjectLinker, huqiang.UIComposite.LinkerMod>)typeof(System.Action<huqiang.UIComposite.ObjectLinker, huqiang.UIComposite.LinkerMod>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)8);
            ((huqiang.UIComposite.ObjectLinker)o).ItemCreate = @ItemCreate;
            return ptr_of_this_method;
        }

        static object get_LayoutCallback_2(ref object o)
        {
            return ((huqiang.UIComposite.ObjectLinker)o).LayoutCallback;
        }

        static StackObject* CopyToStack_LayoutCallback_2(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.UIComposite.ObjectLinker)o).LayoutCallback;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_LayoutCallback_2(ref object o, object v)
        {
            ((huqiang.UIComposite.ObjectLinker)o).LayoutCallback = (System.Func<huqiang.Core.HGUI.UIElement, System.Object, System.Single>)v;
        }

        static StackObject* AssignFromStack_LayoutCallback_2(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Func<huqiang.Core.HGUI.UIElement, System.Object, System.Single> @LayoutCallback = (System.Func<huqiang.Core.HGUI.UIElement, System.Object, System.Single>)typeof(System.Func<huqiang.Core.HGUI.UIElement, System.Object, System.Single>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)8);
            ((huqiang.UIComposite.ObjectLinker)o).LayoutCallback = @LayoutCallback;
            return ptr_of_this_method;
        }



        static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            huqiang.Core.HGUI.UIElement @mod = (huqiang.Core.HGUI.UIElement)typeof(huqiang.Core.HGUI.UIElement).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            huqiang.UIComposite.UIContainer @container = (huqiang.UIComposite.UIContainer)typeof(huqiang.UIComposite.UIContainer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);


            var result_of_this_method = new huqiang.UIComposite.ObjectLinker(@container, @mod);

            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }


    }
}
